/**
 * @Author       : Hejh(3010733382@qq.com)
 * @Version      : V1.0
 * @Date         : 2024-01-24 19:29:18
 * @Description  : 章节管理的路由
 */
const Router = require('koa-router')
const { verifyToken } = require('@/utils/jwt')
const {
  validateSlideCode
} = require('@/middlewares/validateMiddlewares/userValidate')
const chapterController = require('@/controller/chapterController')
const chapterValidate = require('@/middlewares/validateMiddlewares/chapterValidate')
const { verifyAdmin } = require('@/middlewares/validateMiddlewares/verifyAdmin')

const router = new Router()

/**
 * 获取章节列表
 */
router.get(
  '/list',
  // verifyToken(),
  chapterValidate.listChapterValidate,
  chapterController.listChapter
)

/**
 * 新增章节
 */
router.post(
  '/create',
  verifyToken(),
  verifyAdmin(),
  chapterValidate.createChapterValidate,
  chapterController.createChapter
)

/**
 * 更新章节
 */
router.put(
  '/update',
  verifyToken(),
  verifyAdmin(),
  chapterValidate.updateChapterValidate,
  chapterController.updateChapter
)

/**
 * 删除章节
 */
router.delete(
  '/delete',
  validateSlideCode(),
  verifyToken(),
  verifyAdmin(),
  chapterValidate.delChaptersValidate,
  chapterController.delChapters
)

/**
 * 排序章节
 */
router.put(
  '/sort',
  verifyToken(),
  verifyAdmin(),
  chapterValidate.delChaptersValidate,
  chapterController.sortChapters
)

module.exports = router
